require 'MVVM.Sources.View.Adaptor'

ViewModelAdaptor = class('ViewModelAdaptor', Adaptor)

function ViewModelAdaptor:ctor(gameObject, propertyName, binder)
    self.component = gameObject
    self:BindProperty(propertyName, binder)
end

function ViewModelAdaptor:OnViewModelValueChanged(oldValue, newValue)
    if not utils.IsAvailableGameObject(self.component) then return end
    local view = GetLuaObject(self.component)
    if view == nil then return end
    view.Binder.triggerMode = self.binder.triggerMode
    if oldValue ~= newValue then view:Set_BindingContext(newValue) end
    view.Binder:TriggerAll()
end